package icegps.com.pingdj.map.draw;

import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Paint;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.Set;
import java.util.TreeMap;

import icegps.com.pingdj.map.bean.MapStatus;


/**
 * Created by 111 on 2018/3/5.
 */

public class DrawBitmap {

    private Paint bitmapPaint;
    private MapStatus mapStatus;

    public DrawBitmap(MapStatus mapStatus) {
        this.mapStatus = mapStatus;
        bitmapPaint = new Paint();

    }

    /**
     * 绘制bitmap
     *
     * @param canvas
     */
    public void drawBitmap(Canvas canvas) {
        TreeMap<String, Bitmap> bitmaps = mapStatus.getBitmaps();
        Set<String> keySet = bitmaps.keySet();
        for (String key : keySet) {
            Bitmap bitmap = bitmaps.get(key);
            String[] leftAndTop = key.split(",");
            int left = Integer.parseInt(leftAndTop[0]);
            int top = Integer.parseInt(leftAndTop[1]);
            canvas.drawBitmap(bitmap, left, top, bitmapPaint);
        }
    }

}
